#!/bin/sh

# 检查是否配置了 RabbitMQ
if [ -n "$RABBITMQ_HOST" ] && [ -n "$RABBITMQ_PORT" ]; then
  echo "RabbitMQ configuration found. Waiting for RabbitMQ to be ready..."
  # 等待 RabbitMQ 完全启动
  /usr/local/bin/wait-for-it.sh $RABBITMQ_HOST:$RABBITMQ_PORT --timeout=60 --strict -- echo "RabbitMQ is up"
else
  echo "No RabbitMQ configuration found. Skipping wait."
fi

#停留10seconds
sleep 10

# 检查或创建 alembic.ini 文件
if [ ! -f alembic.ini ]; then
    echo "alembic.ini not found, creating a new one."
    cp /app/alembic.ini .
fi

# 其他脚本代码...


# Create alembic.ini
alembic upgrade head


# 启动 Uvicorn 服务器 --reload &
uvicorn main:app --host 0.0.0.0 --port 7000 --workers=4

# 启动 supervisord 服务
# /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf
